package com.mlm.mlmapp.activity;

import android.view.View;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.view.animation.Animation.AnimationListener;

import com.mlm.mlmapp.R;
import com.mlm.mlmapp.interfaces.Prefs_;

import org.androidannotations.annotations.AfterViews;
import org.androidannotations.annotations.EActivity;
import org.androidannotations.annotations.ViewById;
import org.androidannotations.annotations.sharedpreferences.Pref;
//import com.umeng.socialize.P;

@EActivity(R.layout.mlmsplash)
public class MLMSplashActivity extends BaseActivity {

    @ViewById
    View layout_mlmsplash;
    @Pref
    Prefs_ pref;

    @AfterViews
    void init() {
//        try {
//            getVersionName();
//        } catch (Exception e) {
//            e.printStackTrace();
//        }
//		PlatformConfig.setWeixin("wx967daebe835fbeac",
//				"5bb696d9ccd75a38c8a0bfe0675559b3");
//		// 微信 appid appsecret
//		PlatformConfig.setSinaWeibo("3921700954",
//				"04b48b094faeb16683c32669824ebdad");
//		// 新浪微博 appkey appsecret
        AlphaAnimation aa = new AlphaAnimation(0.5f, 1.0f);
        aa.setDuration(2000);
        layout_mlmsplash.startAnimation(aa);
        aa.setAnimationListener(new AnimationListener() {
            @Override
            public void onAnimationEnd(Animation arg0) {
                if ("0".equals(pref.isFirst().get())) {
                    GuideActivity_.intent(MLMSplashActivity.this).start();
                } else {
                    MainActivity_.intent(MLMSplashActivity.this).start();
                }
                MLMSplashActivity.this.finish();
            }

            @Override
            public void onAnimationRepeat(Animation animation) {
            }

            @Override
            public void onAnimationStart(Animation animation) {
            }
        });

    }

//    private String getVersionName() throws Exception {
//        // 获取packagemanager的实例
//        PackageManager packageManager = getPackageManager();
//        // getPackageName()是你当前类的包名，0代表是获取版本信息
//        PackageInfo packInfo = packageManager.getPackageInfo(getPackageName(), 0);
//        String version = packInfo.versionName;
//        return version;
//    }

}
